package branch_algorithm_study;

import java.util.Arrays;
import java.util.Scanner;

public class ABC {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] arr = {scanner.nextInt(), scanner.nextInt(), scanner.nextInt()};
        String user = scanner.next();
        Arrays.sort(arr);
        if (user.equals("ABC")) {
            System.out.println(arr[0] + " " + arr[1] + " " + arr[2]);
        }
        if (user.equals("ACB")) {
            System.out.println(arr[0] + " " + arr[2] + " " + arr[1]);
        }
        if (user.equals("BAC")) {
            System.out.println(arr[1] + " " + arr[0] + " " + arr[2]);
        }
        if (user.equals("BCA")) {
            System.out.println(arr[1] + " " + arr[2] + " " + arr[0]);
        }
        if (user.equals("CAB")) {
            System.out.println(arr[2] + " " + arr[0] + " " + arr[1]);
        }
        if (user.equals("CBA")) {
            System.out.println(arr[2] + " " + arr[1] + " " + arr[0]);
        }
    }
}

